#
cmake_minimum_required(VERSION 3.3)
PROJECT(BaseLib)

#工程属性设置
set(CMAKE_DEBUG_POSTFIX _d)
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

#变量声明定义

SET( 
	FREETYPE_LIBRARY
    "${PROJECT_SOURCE_DIR}/ThirdParty/freetype-2.6.3-win64/lib/freetype.lib"
	CACHE FILEPATH 
	"freetype library file."
	)

SET( 
	FREETYPE_INCLUDE_DIRS
    "${PROJECT_SOURCE_DIR}/ThirdParty/freetype-2.6.3-win64/include/freetype2" 
	CACHE PATH
	"freetype include directory."
	)

if (NOT DEFINED ENV{DXSDK_DIR})
	message(FATAL_ERROR "Please Install DXSDK first!")
else()
	SET( DXSDK_DIR
		"$ENV{DXSDK_DIR}"
		CACHE PATH
		"DirectX SDK install path."
	)
endif()

set(DX_HEADERS ${DXSDK_DIR}/Include )
set(DX_LIBS ${DXSDK_DIR}/Lib/x64 )


set(PUBLIC_HEADERS  ${PROJECT_SOURCE_DIR}/Include)
set(INSTALL_DIR  ${PROJECT_BINARY_DIR}/Install)

# Debug模式下，生成的exe/dll 都放入同一个目录下。
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/Debug)

set(TOLUABIN ${INSTALL_DIR}/tolua++bin.exe)

include_directories(
	${PUBLIC_HEADERS}
	${DX_HEADERS}
	${FREETYPE_INCLUDE_DIRS}
)

link_directories(
	${LIBRARY_DIR}
	${DX_LIBS}
	${FREETYPE_LIBRARY}
)

add_subdirectory(Source)

option(BUILD_LUA_LIB "是否编译Lua DLL库" OFF)
option(BUILD_LUA_BIN "是否编译Lua.exe" OFF)
option(BUILD_TOLUA_LIB "是否编译TOLUA DLL库" OFF)
option(BUILD_TOLUA_BIN "是否编译tolua.exe" OFF)
option(BUILD_W32_LIB "是否编译w32 dll库" OFF)
option(BUILD_TOOL_EDITOR "是否编译Editor" OFF)
option(BUILD_TOOL_IME "是否编译ime-tsf" OFF)
option(BUILD_TOOL_MKGLYPH "是否编译mkglyph" OFF)

#子工程

if(BUILD_LUA_LIB)
	add_subdirectory(Source/lua-5.1.4)
endif()

if(BUILD_TOLUA_LIB)
	message("build tolua.dll")
	add_subdirectory(Source/tolua++)
endif()

if(BUILD_TOLUA_BIN)
	add_subdirectory(Source/tolua++bin)
endif()

if(BUILD_W32_LIB)
	add_subdirectory(Source/w32)
endif()

if(BUILD_TOOL_EDITOR)
	add_subdirectory(Target/Editor)
endif()

if(BUILD_TOOL_IME)
	add_subdirectory(Target/test_ime)
endif()

if(BUILD_TOOL_MKGLYPH)
	add_subdirectory(Target/mkglyph)
endif()

set(CPACK_GENERATOR ZIP)
include(CPack)
